home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xa;
-
- import com.extensibility.app.BaseApplication;
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.net.Socket;
-
- class Connection extends Thread {
- public static final String STARTED = "Started";
- protected static final String WHOMEVER = "whomever";
- protected Socket sock;
- // $FF: renamed from: in java.io.DataInputStream
- protected DataInputStream field_0;
- protected DataOutputStream out;
- protected String fromClient = null;
-
- public Connection(Socket var1) {
- this.sock = var1;
-
- try {
- this.out = new DataOutputStream(this.sock.getOutputStream());
- this.field_0 = new DataInputStream(this.sock.getInputStream());
- } catch (IOException var5) {
- try {
- this.sock.close();
- } catch (IOException var4) {
- }
-
- System.err.println(String.valueOf("Exception while getting socket streams: ").concat(String.valueOf(var5)));
- return;
- }
-
- ((Thread)this).setDaemon(true);
- BaseApplication.getApplication().addApplicationListener(new ApplicationAdapter(this));
- this.sendNotification("Started", (String)null, "");
- ((Thread)this).start();
- }
-
- public void run() {
- byte[] var4 = new byte[2048];
-
- try {
- while(true) {
- int var7 = this.field_0.readUnsignedByte();
- int var8 = this.field_0.readUnsignedByte();
- int var9 = this.field_0.readUnsignedByte();
- int var10 = this.field_0.readUnsignedByte();
- int var5 = var10 << 24 | var9 << 16 | var8 << 8 | var7;
- if (var5 == -1 || var5 == 0) {
- break;
- }
-
- String var2 = "";
-
- do {
- int var6 = this.field_0.read(var4, 0, var5);
- String var3 = new String(var4, 0, var6);
- var2 = var2.concat(var3);
- var5 -= var6;
- } while(var5 > 0);
-
- String var11 = this.getAttr(var2, "from");
- if (this.fromClient == null) {
- this.fromClient = var11;
- }
-
- String var12 = this.getAttr(var2, "uri");
- BatchProcessor var13 = new BatchProcessor(var2);
- (new Thread(var13)).start();
- if (var2.indexOf("PrintDiagram") != -1) {
- this.sendNotification("PrintDiagram", var11, var12);
- }
- }
- } catch (IOException var23) {
- System.out.println(var23);
- } finally {
- try {
- this.sock.close();
- } catch (IOException var22) {
- }
-
- }
-
- }
-
- private void sendNotification(String var1, String var2, String var3) {
- if (var2 == null) {
- var2 = "whomever";
- }
-
- String var4 = String.valueOf(String.valueOf(String.valueOf("<?xml version=\"1.0\"?>\r\n<XANotification to = \"").concat(String.valueOf(var2))).concat(String.valueOf("\">\r\n"))).concat(String.valueOf(" "));
- String var5 = "</XANotification>\r\n";
- String var6 = String.valueOf(String.valueOf(" uri = \"").concat(String.valueOf(var3))).concat(String.valueOf("\""));
- String var7 = "";
- byte[] var8 = new byte[2048];
- if (var1.equals("OpenSchema")) {
- var7 = String.valueOf(String.valueOf(String.valueOf(String.valueOf(var4).concat(String.valueOf("<SchemaOpened"))).concat(String.valueOf(var6))).concat(String.valueOf("/>\r\n"))).concat(String.valueOf(var5));
- } else if (!var1.equals("SaveSchema") && !var1.equals("SaveAsSchema")) {
- if (var1.equals("PrintDiagram")) {
- var7 = String.valueOf(String.valueOf(String.valueOf(String.valueOf(var4).concat(String.valueOf("<DiagramPrinted"))).concat(String.valueOf(var6))).concat(String.valueOf("/>\r\n"))).concat(String.valueOf(var5));
- } else if (var1.equals("CloseSchema")) {
- var7 = String.valueOf(String.valueOf(String.valueOf(String.valueOf(var4).concat(String.valueOf("<SchemaClosed"))).concat(String.valueOf(var6))).concat(String.valueOf("/>\r\n"))).concat(String.valueOf(var5));
- } else if (var1.equals("Exit")) {
- var7 = String.valueOf(String.valueOf(var4).concat(String.valueOf("<Exited/>\r\n"))).concat(String.valueOf(var5));
- } else {
- if (!var1.equals("Started")) {
- return;
- }
-
- var7 = String.valueOf(String.valueOf(String.valueOf(String.valueOf(var4).concat(String.valueOf("<"))).concat(String.valueOf(var1))).concat(String.valueOf("/>\r\n"))).concat(String.valueOf(var5));
- }
- } else {
- var7 = String.valueOf(String.valueOf(String.valueOf(String.valueOf(var4).concat(String.valueOf("<SchemaSaved"))).concat(String.valueOf(var6))).concat(String.valueOf("/>\r\n"))).concat(String.valueOf(var5));
- }
-
- int var9 = var7.length();
- var8[0] = (byte)(var9 & 255);
- var8[1] = (byte)((var9 & '\uff00') >> 8);
- var8[2] = (byte)((var9 & 16711680) >> 16);
- var8[3] = (byte)((var9 & -16777216) >> 24);
-
- for(int var10 = 0; var10 < var7.length(); ++var10) {
- var8[4 + var10] = (byte)var7.charAt(var10);
- }
-
- try {
- this.out.write(var8, 0, var7.length() + 4);
- this.out.flush();
- } catch (Exception var12) {
- }
-
- }
-
- String getAttr(String var1, String var2) {
- int var3 = var1.indexOf(var2);
- if (var3 == -1) {
- return "";
- } else {
- String var4 = var1.substring(var3 + 4);
- var3 = var4.indexOf("\"");
- if (var3 == -1) {
- return "";
- } else {
- var4 = var4.substring(var3 + 1);
- var3 = var4.indexOf("\"");
- if (var3 == -1) {
- return "";
- } else {
- var4 = var4.substring(0, var3);
- return var4;
- }
- }
- }
- }
-
- // $FF: synthetic method
- static void access$2000071(Connection var0, String var1, String var2, String var3) {
- var0.sendNotification(var1, var2, var3);
- }
- }
-